package com.situation.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.situation.pojo.DO.BizConsumer;
import com.situation.mapper.BizConsumerMapper;
import com.situation.service.BizConsumerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (BizConsumer)表服务实现类
 *
 * @author makejava
 * @since 2021-12-06 19:39:25
 */
@Service
public class BizConsumerServiceImpl implements BizConsumerService {

    @Autowired
    private BizConsumerMapper bizConsumerMapper;

    /**
     * 通过id查询
     *
     * @param id 主键
     * @return
     */
    @Override
    public BizConsumer queryById(Long id) {
        return bizConsumerMapper.queryById(id);
    }

    /**
     * 添加
     *
     * @param bizConsumer 实例对象
     * @return
     */
    @Override
    public BizConsumer insert(BizConsumer bizConsumer) {
        int i = bizConsumerMapper.insert(bizConsumer);
        if (i > 0) {
            return bizConsumer;
        }
        return null;
    }

    /**
     * 修改
     *
     * @param bizConsumer 实例对象
     * @return
     */
    @Override
    public BizConsumer update(BizConsumer bizConsumer) {
        int i = bizConsumerMapper.update(bizConsumer);
        if (i > 0) {
            return bizConsumer;
        }
        return null;
    }

    /**
     * 删除
     * @param id 主键
     * @return boolean
     */
    @Override
    public boolean deleteById(Long id) {
        int i = bizConsumerMapper.deleteById(id);
        return i > 0;
    }

    /**
     * 查询所有
     * @return 集合
     */
    @Override
    public List<BizConsumer> queryAll() {
        return bizConsumerMapper.queryAll();
    }

    /**
     * 多条件查询
     *
     * @param consumer 条件对象
     * @return 集合
     */
    @Override
    public PageInfo<BizConsumer> queryAllByCon(int pageNum,int pageSize,BizConsumer consumer) {
        PageHelper.startPage(pageNum,pageSize);
        return new PageInfo<>(bizConsumerMapper.queryAllByCon(consumer));
    }
}